package com.room.core.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {
    private Integer code;
    private boolean success;
    private String msg;
    private Object data;

    public static R success() {
        return new R(1, true, "操作成功", null);
    }

    public static R success(Object data) {
        return new R(1, true, "操作成功", data);
    }

    public static R success(String msg) {
        return new R(1, true, msg, null);
    }

    public static R fail() {
        return new R(0, false, "操作失败", null);
    }

    public static R fail(String msg) {
        return new R(0, false, msg, null);
    }

    public static R notLogin() {
        return new R(401, false, "请先登录", null);
    }
}
